package com.guanyong.services;

import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * Created by mxk on 2017/7/3.
 */
@Service
public class CommFunc {
    public static HashMap<Integer,String> filmTypDic;

    public static HashMap<Integer,String> countryNameDic;
    static  {
        filmTypDic=new HashMap<Integer, String>();
        filmTypDic.put(0,"喜剧");
        filmTypDic.put(1,"爱情");
        filmTypDic.put(2,"动作");
        filmTypDic.put(3,"恐怖");
        filmTypDic.put(4,"科幻");
        filmTypDic.put(5,"剧情");
        filmTypDic.put(6,"犯罪");
        filmTypDic.put(7,"奇幻");
        filmTypDic.put(8,"战争");
        filmTypDic.put(9,"悬疑");
        filmTypDic.put(10,"动画");
        filmTypDic.put(11,"伦理");
        filmTypDic.put(12,"纪录");
        filmTypDic.put(13,"传记");
        filmTypDic.put(14,"歌舞");
        filmTypDic.put(15,"家庭");
        filmTypDic.put(16,"历史");
        filmTypDic.put(17,"惊悚");
        filmTypDic.put(18,"文艺");

        countryNameDic=new HashMap<Integer, String>();
        countryNameDic.put(1,"中国");
        countryNameDic.put(2,"香港");
        countryNameDic.put(3,"台湾");
        countryNameDic.put(4,"美国");
        countryNameDic.put(5,"日本");
        countryNameDic.put(6,"韩国");
        countryNameDic.put(7,"法国");
        countryNameDic.put(8,"德国");
        countryNameDic.put(9,"意大利");
        countryNameDic.put(10,"荷兰");
        countryNameDic.put(11,"丹麦");
        countryNameDic.put(12,"加拿大");
        countryNameDic.put(13,"芬兰");
        countryNameDic.put(14,"葡萄牙");
        countryNameDic.put(15,"瑞典");
        countryNameDic.put(16,"瑞士");
        countryNameDic.put(17,"西班牙");
        countryNameDic.put(18,"其他");
    }

    public static String   GetCountryNameById(Integer id){
        if (id!=null && countryNameDic.containsKey(id)){
            return countryNameDic.get(id);
        }
        else{
            return countryNameDic.get(14);
        }
    }



    public static String   GetFilmTypeNameById(String idlist){
        if (idlist!=null ){
            String[] ary=idlist.split("");
            String tempName="";
            for (Integer i=0;i<ary.length;i++){
                if (ary[i].equals("1")){
                    tempName+="/"+filmTypDic.get(i);
                }
            }
            if (tempName.length()>0){
                tempName=tempName.substring(1);

            }
            return tempName;
        }
        else{
            return "";
        }
    }
}
